package com.imooc.pojo.bo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;

@ApiModel(value = "用户注册所传参数BO", description = "前端所传参数")
public class UserBO {

    @NotBlank(message = "用户名不能为空")
    @Length(min = 1, max = 20, message = "用户名长度必须在1-20位之间")
    @ApiModelProperty(value = "用户名", name = "username", example = "imooc", required = true)
    private String username;

    @NotBlank(message = "密码不能为空")
    @Length(min = 6 , message = "密码长度必须在6-20位之间")
    @ApiModelProperty(value = "密码", name = "password", example = "123456", required = true)
    private String password;

    @NotBlank(message = "确认密码不能为空")
    @Length(min = 6, max = 20, message = "密码长度必须在6-20位之间")
    @ApiModelProperty(value = "确认密码", name = "confirmPassword", example = "123456", required = true)
    private String confirmPassword;

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getConfirmPassword() {
        return confirmPassword;
    }

    public void setConfirmPassword(String confirmPassword) {
        this.confirmPassword = confirmPassword;
    }

    @Override
    public String toString() {
        return "UserBO{" +
                "username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", confirmPassword='" + confirmPassword + '\'' +
                '}';
    }

    /**
     * 判断密码和确认密码是否一致
     * */
    public boolean isTrue(String password, String confirmPassword) {
        return password.equals(confirmPassword) ? true : false;
    }
}
